/*->h.def */


#define DRAW   0xAFF
#define TEXT   0xFFF
#define CROSSF 0x492
#define CODE   -1

/***************************************************************************/
                        /* structure of vm memory block */

typedef struct buffer
{
  struct buffer **  anchor;  /* this points at the anchor in the source   */
  int     len;               /* amount of stuff in buffer */
  int     maxlen;            /* maximum length of buffer  */
  int     previous;          /* offset of previous buffer */
  int     goffset;           /* offset of gap in buffer   */
  char    buff[4];           /* character buffer          */
} buffer;

/***************************************************************************/

/************ File structure ***********************/ 

typedef struct
{
  int  object;
  int  length;
  int  load;
  int  exec;
  int  acc;
  int  type;
  char name[12];
} fstat;


/****************************************************************************/

/************* Box structure ************************/


typedef struct xstr
{
 struct xstr * next;
 struct xstr * prev;
 char          type;                                           /* X type  */
 char            f1;                                           /* flags   */
 char            f2;
 char            f3;  
 int        x,y,w,h;                                           /* 7 words */

   union  {

         struct {                        /* 1 word */
                 struct xstr * box;
                } vbox;


         struct {                         /* 8 words */
                 struct xstr * textbox;
                 buffer *      txanc;     /* anchor for text buffer         */
                 buffer *      vlanc;     /* anchor for line buffer         */
                 int           foffset;   /* highest flowed point           */
                 int           doffset;   /* point that must be reflowed to */
                 int           hoffset;   /* highest unflowed point         */
                 int           qoffset;   /* quick reflow                   */
                 struct xstr * link;      /* temporary link                 */

                } source;
                  

         struct {                        /* 7 words */
                 struct xstr * picbox;
                 buffer *      anchor;
                 int           type;
                 int           x0;
                 int           y0;
                 int           x1;
                 int           y1;
                } picture;
      

         struct {                        /* 14 words           */
                 struct xstr * parent;
                 struct xstr * child;
                 struct xstr * frame;    /* frame pointer      */
                 struct xstr * fnext;    /* flow next          */
                 struct xstr * fprev;    /* flow prev          */
                 int           colour;   /* text colour        */
                 int           trans;    /* transparent ?      */
                 int           i;        /* inset              */
                 int           o;        /* outset             */

                 struct xstr * vbox;     /* first vibox        */
                 int           bytes;    /* bytes in  box      */
                 int           lines;    /* lines in  box      */
                 int           influx;   /* inflow to box      */
                 int           linflux;  /* inflow in lines    */
                 struct xstr * oldvbox;
                } text;
                       

         struct {                        /* 17 words                      */
                 struct xstr * parent;
                 struct xstr * child;
                 struct xstr * frame;    /* frame pointer                 */
                 struct xstr * fnext;    /* next pic box with this source */
                 struct xstr * fprev;    /* prev pic box with this source */
                 int           colour;   /* picture colour                */
                 int           trans;    /* transparent ?                 */
                 int           i;        /* inset                         */
                 int           o;        /* outset                        */

                 int           file;     /* file handle for this picbox   */
                 int           xmul;     /* xscale                        */
                 int           xdiv;     
                 int           ymul;     /* yscale                        */
                 int           ydiv;
                 int           xshift;   /* x shift                       */
                 int           yshift;   /* y shift                       */
                } pict;


         struct
                {                         /* 14 words */
                 struct xstr * parent;
                 int           colour;
                 int           style;
                 int           endcaps;
                 int           ox;
                 int           oy;
                 int           ex;
                 int           ey;
                 int           thickness;

                 int           bx;
                 int           by;
                 int           bh;
                 int           bw;
                 int           hy;

                } line;


         struct
                {                        /* 7 words */
                 struct xstr * parent;
                 int           colour;   /* frame colour       */
                 int           size;     /* frame size         */
                 int           spcol;    /* use sprite colours */
                 char          name[12]; /* name of frame      */
                } frame;


         struct {
                 struct xstr * parent;    /* so it looks like a text box ! */
                 struct xstr * child;
                 struct xstr * gux;
                 struct xstr * guy;
                 int           number;    /* running  page  number */
                 int           guxa[2];
                 int           guya[2];
                } page;


         struct {                      /* 13 words */
                 struct xstr * page;   /* first page in section          */
                 struct xstr * source; /* first source in section        */
                 int np;               /* number of pages                */
                 short int secno;      /* section number                 */
                 char  format;         /* page number format             */
                 char  start;          /* 1 == start numbering from here */
                 int number;           /* starting number                */

                 char prs[32];         /* pointer to printer string */
                } section;


         struct {                       /* 4 words */
                 struct xstr * parent;  /* points back to page       */
                 struct xstr * child;   /* points to any child box's */
                 struct xstr * frame;   /* frame                     */
                 struct xstr * sub;     /* points to sub text box's  */
                } shell;

         } u;

} xstr;



#define NUMBER     u.page.number
#define FNEXT      u.text.fnext
#define FPREV      u.text.fprev
#define VBOX       u.text.vbox



/* f1 flags                   */

#define MODHSECT 0x1
#define MODFSECT 0x2
#define FULLBOX  0x4
#define CLEAROBJ 0x8



typedef struct vec              /* position vector  */
{
 xstr *     section;            /* section          */
 xstr *     source;             /* source           */
 int        off;                /* offset in source */

 xstr *     page;               /* page             */
 xstr *     box;                /* box              */

 int        vloff;              /* vline offset in vl buff */
 int        loff;               /* line offset in source   */
 int        vlboff;             /* box  offset in vl buff  */
 int        boff;               /* box  offset in source   */

 int        fstyle;             /* fstyle at start of line */

 int        xps;                /* coords of page  */
 int        yps;
 int        x;                  /* coords of point */
 int        y;

 int        ld;                 /* fmaxld for line */

 int        vdi;                /* vdi for point   */
} vec;



#define XPAGE    0 
#define XTEXT    1
#define XPICT    2 
#define XLINE    3 
#define XMAIN    4 
#define XHEADER  5
#define XFOOTER  6 
#define XVBOX    7 
#define XSECT    8

#define XACTOUT  10 
#define XACTRHM  11 
#define XACTRHB  12 
#define XACTBTM  13 
#define XGUIDEX  14 
#define XGUIDEY  15 

#define XACTRHT  17
#define XACTTPM  18
#define XACTLHT  19
#define XACTLHM  20
#define XACTLHB  21
#define XSOURCE  22 
#define XFRAME   23
#define XSHELL   24
#define XPICTURE 25

#define XACTLO   26
#define XACTLE   27

#define XFREE32  28
#define XFREE64  XFREE32+1
#define XFREE96  XFREE64+1
#define XFREE128 XFREE96+1



#define  SIZEBUFF(bp) ((bp)->len-sizeof(buffer)+4)





